package com.sz.common.base.dao.ext;


import com.sz.common.base.dao.schema.TableSchema;
import com.sz.common.base.entity.Entity;

import java.io.Serializable;
import java.util.List;

/**
 * Package: com.sz.common.base.dao.ext <br>
 * Function: TODO: ADD FUNCTION <br>
 * Author: Charles. <br>
 * Date: 2017-02-22 15:20:00.
 */
public interface EntityDao {

    Object insertEntity(TableSchema tableSchema, Entity entity);

    List<Object> insertEntities(TableSchema tableSchema, List<Entity> entities);

    /**
     * @param tableSchema
     * @param entity
     * @param excludeEmptyField
     */
    void updateEntity(TableSchema tableSchema, Entity entity, boolean excludeEmptyField);

    void updateEntities(TableSchema tableSchema, List<Entity> entities, boolean excludeEmptyField);

    /**
     * @param tableSchema
     * @param id
     */
    void deleteEntity(TableSchema tableSchema, Serializable id);

    void deleteEntities(TableSchema tableSchema, Serializable[] ids);

    <T> List<T> selectEntities(String tableName, String keyName, Object keyValue, Class<T> clazz);

    /**
     * @param tableName
     * @param whereFields
     * @param clazz
     * @param <T>
     * @return
     */
    <T> List<T> selectEntities(String tableName, List<FieldExp> whereFields, Class<T> clazz);

    <T> T selectEntity(String tableName, String keyName, Object keyValue, Class<T> clazz);

    /**
     * @param tableName
     * @param whereFields
     * @param clazz
     * @param <T>
     * @return
     */
    <T> T selectEntity(String tableName, List<FieldExp> whereFields, Class<T> clazz);
}
